<div ng-controller="salesPersonController">
<crm-main-nav  nav-c="sales" page-title="公司销售计划"></crm-main-nav>
<!-- 面包屑 -->
<div class="container">
  <ol class="breadcrumb">
      <li>CRM系统</li>
      <li>销售计划</li>
      <li class="active">分配计划</li>
  </ol>
</div>
<!-- 内容 -->
<div class="container">
  <div class="panel panel-default">
    <div class="panel-heading">
      <h3 class="panel-title">分配分公司销售计划</h3>
    </div>
    <div class="panel-body">
       <table class="table table-bordered">
        <thead>
          <tr>
            <th>分公司</th>
            <th>计划月份</th>
            <th>保底计划</th>
            <th>任务计划</th>
            <th>目标计划</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>{{companyPlan.branch_company_id}}</td>
            <td>{{companyPlan.month}}</td>
            <td>{{companyPlan.guarantee_planning}}</td>
            <td>{{companyPlan.task_planning}}</td>
            <td>{{companyPlan.target_planning}}</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div> 
</div>
    <!-- 添加销售人员计划 ng-class="{'has-error':!add_sales_name_form.target_planning.$valid && (!add_sales_name_form.$pristine || add_sales_name_form.$submitted)}" -->
<crm-panel title="添加销售人员计划">
  <form class="form-horizontal" role="form" name="add_sales_name_form" ng-submit="addSalesNameForm(add_sales_name_form.$valid)" novalidate>
      <div class="form-group">
        <input type="hidden" ng-init="addSalesData.type=2">
        <label class="col-sm-1 control-label">销售人员：</label>
        <div class="col-sm-2">
        	<user-select current-id="addSalesData.user_id" company-id="{{companyId}}"></user-select>
        </div>
        <label class="col-sm-1 control-label">计划月份：</label>
        <div class="col-sm-2" date-input style-date="YYYY-MM" get-date="addSalesData.month"></div>
        <label class="col-sm-1 control-label">保底计划：</label>
        <div class="col-sm-2">
          <input type='text' class="form-control" name="guarantee_planning" ng-model="addSalesData.guarantee_planning" required/>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-1 control-label">任务计划：</label>
        <div class="col-sm-2">
          <input type='text' class="form-control" name="task_planning" ng-model="addSalesData.task_planning" required/>
        </div>
        <label class="col-sm-1 control-label">目标计划：</label>
        <div class="col-sm-2">
          <input type='text' class="form-control" name="target_planning" ng-model="addSalesData.target_planning" required/>
        </div>
        <div class="col-sm-1">
          <button type="submit" class="btn btn-primary">添加</button>
        </div>
      </div>
    </form>
</crm-panel>
    <!-- 销售计划列表 -->
<crm-panel title="销售人员计划列表">
<div class="panel-body">
  <form class="form-horizontal" role="form" ng-submit="searchSalesForm()">
    <div class="form-group">
      <label class="col-sm-1 control-label">销售人员：</label>
      <div class="col-sm-2">
      	<user-select current-id="formData.user_id" company-id="{{companyId}}"></user-select>
      </div>
      <div class="col-sm-1">
        <button type="submit" class="btn btn-primary">搜索</button>
      </div>
    </div>
  </form>
  <table class="table table-bordered" id="table_list" ng-show="table_list.length>0">
    <thead>
      <tr >
        <th>选择</th>
        <th>分公司</th>
        <th>销售人员</th>
        <th>计划月份</th>
        <th>保底计划</th>
        <th>任务计划</th>
        <th>目标计划</th>
        <th>实际业绩金额</th>
        <th ng-if="user.type>=3">操作</th>
      </tr>
    </thead>
    <tbody>
      <tr ng-repeat="v in currentData track by $index">
        <td><input type="checkbox" value="" ng-model='checked[$index]' ng-init="checked[$index]=false"></td>
        <td>{{v.branch_company}}</td>
        <td>{{v.user_name}}</td>
        <td>{{v.month | date:'yyyy-MM'}}</td>
        <td>{{v.guarantee_planning}}</td>
        <td>{{v.task_planning}}</td>
        <td>{{v.target_planning}}</td>
        <td>{{v.reality_money}}</td>
        <td>
          <a href="javascript:void(0);" class="btn btn-default btn-sm" data-toggle="modal" data-target="#myModal" ng-click="setplan(v)">修改</a>
          <a href="javascript:void(0);" class="btn btn-default btn-sm" ng-click="delplan(v)">删除</a> 
        </td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <td>小计</td>
        <td>-</td>
        <td>-</td>
        <td>-</td>
        <td>{{sumData.guarantee_planning}}</td>
        <td>{{sumData.task_planning}}</td>
        <td>{{sumData.target_planning}}</td>
        <td>{{sumData.reality_money}}</td>
        <td></td>
      </tr>
    </tfoot>
  </table>
  <button type="button" class="btn btn-primary" ng-click="allSelect()">全选</button>
  <button type="button" class="btn btn-primary" ng-click="delSubmit()">删除</button>
</div>
</crm-panel>
  <div class="container">
    <pagination current-data="currentData" all-data="{{table_list}}"></pagination>
  </div>
<!-- 模态框 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
      <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel">修改</h4>
          </div>
          <div class="modal-body">
            <form class="form-horizontal"  ng-submit="setForm()" id="set_form">
              <div class="form-group">
                <input type="hidden" ng-init="addSalesData.type=1">
                <label class="col-sm-2 control-label">分公司：</label>
                <div class="col-sm-4">
                  <company-select class="form-control" required current-id="setSalesData.branch_company_id"></company-select>
                </div>
                <label class="col-sm-2 control-label">计划月份：</label>
                <div class="col-sm-4" date-input style-date="YYYY-MM" get-date="setSalesData.month"></div>
              </div>  
              <div class="form-group">  
                <label class="col-sm-2 control-label">保底计划：</label>
                <div class="col-sm-3">
                  <input type='text' class="form-control" required ng-model="setSalesData.guarantee_planning"/>
                  </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">任务计划：</label>
                <div class="col-sm-4">
                  <input type='text' class="form-control" required ng-model="setSalesData.task_planning"/>
                </div>
                <label class="col-sm-2 control-label">目标计划：</label>
                <div class="col-sm-4">
                  <input type='text' class="form-control" required ng-model="setSalesData.target_planning"/>
                </div>
              </div>
            </form>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary" ng-click="setForm()">确定</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
          </div>
      </div>
  </div>
</div>
</div>

